package com.ai.platform.system.web;

import com.ai.platform.core.annotation.AIController;
import com.ai.platform.core.annotation.RestInvokeService;
import com.ai.platform.core.controller.BaseController;
import com.ai.platform.model.dto.Output;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.hibernate.validator.constraints.Length;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.validation.constraints.NotNull;

/**
 * @Auther: yeyingsheng
 * @Date: 2018/5/28 20:11
 * @Description:用户管理
 */
@AIController
@RequestMapping("/system/user")
public class UserController extends BaseController{

    private final Logger logger = LoggerFactory.getLogger(UserController.class);

    /**
     * 用户管理
     * @return
     */
    @GetMapping(value = "/user")
    @RequiresPermissions("user::user")
    public String toUser(){
        return "system/user/user";
    }

    /**
     * 用户管理[列表]
     * @return
     */
    @RequestMapping(value = "/userList")
    @RequiresPermissions("user::list")
    @RestInvokeService(serviceName = "sysUserServiceImpl",method = "listUser")
    public Output listUser(){
        return super.getOutput();
    }

    /**
     * 用户管理[保存]
     * @return
     */
    @PostMapping(value = "/saveUser")
    @RequiresPermissions("user::save")
    @RestInvokeService(serviceName = "sysUserServiceImpl",method = "saveUser")
    public Output saveUser(
            @NotNull String account,
            @Length(min = 6,max = 12,message = "密码长度在6-12位之间") String password,
            @NotNull String roleIds){
        return super.getOutput();
    }

    /**
     * 用户管理[修改]
     * @return
     */
    @PostMapping(value = "/updateUser")
    @RequiresPermissions("user::update")
    @RestInvokeService(serviceName = "sysUserServiceImpl",method = "saveUser")
    public Output updateUser(@NotNull String id,
                             @Length(min = 6,max = 12,message = "密码长度在6-12位之间") String password,
                             @NotNull String roleIds){
        return super.getOutput();
    }

    /**
     * 用户管理[删除]
     * @return
     */
    @PostMapping(value = "/deleteUser")
    @RequiresPermissions("user::delete")
    @RestInvokeService(serviceName = "sysUserServiceImpl",method = "deleteUser")
    public Output deleteUser(@NotNull String ids){
        return super.getOutput();
    }

}
